package com.kool.leitu.bean;

import lombok.Data;

/**
 * @description:
 * @author: tianhe
 * @create: 2019/02/12 14:00
 */
@Data
public class ColumnsBean {
    protected String tableCatalog;
    protected String tableSchema;
    protected String tableName;
    protected String columnName;
    protected Long ordinalPosition;
    protected String columnDefault;
    protected String isNullable;
    protected String dataType;
    protected Long characterMaximumLength;
    protected Long characterOctetLength;
    protected Long numericPrecision;
    protected Long numericScale;
    protected Long datetimePrecision;
    protected String characterSetName;
    protected String collationName;
    protected String columnType;
    protected String columnKey;
    protected String extra;
    protected String privileges;
    protected String columnComment;
    protected String generationExpression;


    public static String transferType(String dataType) {
        String type = null;
        if ("VARCHAR".equalsIgnoreCase(dataType)
                || ("CHAR".equalsIgnoreCase(dataType))) {
            type = "String";
        } else if ("INT".equalsIgnoreCase(dataType)) {
            type = "int";
        } else if ("DOUBLE".equalsIgnoreCase(dataType)) {
            type = "double";
        } else if ("DATE".equalsIgnoreCase(dataType)) {
            type = "java.util.Date";
        } else if ("TIME".equalsIgnoreCase(dataType)) {
            type = "java.sql.Time";
        } else if ("TIMESTAMP".equalsIgnoreCase(dataType)) {
            type = "java.sql.Timestamp";
        } else if ("DECIMAL".equalsIgnoreCase(dataType)) {
            type = "java.math.BigDecimal";
        } else if ("BIGINT".equalsIgnoreCase(dataType)) {
            type = "Long";
        } else if ("DATETIME".equalsIgnoreCase(dataType)) {
            type = "java.util.Date";
        } else{
            type = "Object";
        }
        return type;
    }
}
